博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Open edX课程数据的存储方式
阅读量:5898 次
发布时间:2019-06-19

本文共 5605 字,大约阅读时间需要 18 分钟。

  hot3.png

openEDX课程数据的存储方式在官方文档中一节说明了其设计的核心思想,本文简单解释一下它的存储方式并通过查看数据库存储的内容来进一步了解它。

每个课程的数据都分三部分:

  • Course Index 课程最基本的数据,比如课程代码、单位等,其中最重要的是两个ObjectID,一个是已发布的课程Course Structures,另一个编辑中的课程Course Structures
  • Course Structures,记录着课程的主要内容和结构,包含多个block,其中默认包含course和overview两个block,所有的block都有自己的ObjectID,它指向XBlock Definitions
  • XBlock Definitions 记录block的具体数据。

下面是mongodb中的collections

root@i-7kvy76cm:/edx# mongoMongoDB shell version: 2.6.11connecting to: test> use edxappswitched to db edxapp> show collectionsfs.chunksfs.filesmodulestore.active_versions # 即是Course Indexmodulestore.definitions # 即是XBlock Definitionsmodulestore.structures # 即是Course Structuressystem.indexes

modulestore.active_versions中的数据大致是这样

{ "_id": ObjectId("5632e46950e3432ed9f51b08"), "course": "test10code", # 课程代码 "edited_on": ISODate("2015-10-30T03:30:49.380Z"), "run": "2015", "versions": { "draft-branch": ObjectId("5632e46950e3432ed9f51b07"),# 编辑版Course Structures "published-branch": ObjectId("5632e46950e3432ed9f51b09") }, # 发布版Course Structures "search_targets": { "wiki_slug": "test10org.test10code.2015" }, "org": "test10org", # 单位代码 "edited_by": NumberLong(9), "schema_version": 1, "last_update": ISODate("2015-10-30T03:30:49.564Z")}

Course Structures的json数据大致是这样:

{ "_id": ObjectId("5632e84650e3432ed9f51b0b"), "edited_by": NumberLong(9), "previous_version": ObjectId("5632e83550e3432edcf51b07"), "original_version": ObjectId("5632e46950e3432ed9f51b07"), "schema_version": 1, "edited_on": ISODate("2015-10-30T03:47:18.352Z"), "blocks": [ # blocks列表,第一个是新添加一个章节数据test-chapter1 { "definition": ObjectId("5632e83550e3432edcf51b06"), "block_type": "chapter", "block_id": "7270a053884041a2b2cc0e64065970f2", "fields": { "display_name": "test-chapter1" }, "defaults": { }, "edit_info": { "edited_by": NumberLong(9), "previous_version": ObjectId("5632e83550e3432edcf51b07"), "original_usage_version": null, "original_usage": null, "edited_on": ISODate("2015-10-30T03:47:18.352Z"), "source_version": null, "update_version": ObjectId("5632e84650e3432ed9f51b0b") } }, { # 第二是默认存在的基本course的block,它设定了课程包含哪几大块内容,比如课件、更新通知、教材、论坛、wiki等 "definition": ObjectId("5632e46950e3432ed9f51b06"), "block_type": "course", "block_id": "course", "fields": { "display_name": "test10name", "language": "en", "tabs": [ { "type": "courseware", "name": "Courseware" }, { "type": "course_info", "name": "Course Info" }, { "type": "textbooks", "name": "Textbooks" }, { "type": "discussion", "name": "Discussion" }, { "type": "wiki", "name": "Wiki" }, { "type": "progress", "name": "Progress" } ], "discussion_topics": { "一般": { "id": "course" } }, "start": ISODate("2030-01-01T00:00:00Z"), "children": [ [ "chapter", "7270a053884041a2b2cc0e64065970f2" ] ] }, "defaults": { }, "edit_info": { "edited_by": NumberLong(9), "previous_version": ObjectId("5632e46950e3432ed9f51b07"), "original_usage_version": null, "original_usage": null, "edited_on": ISODate("2015-10-30T03:47:01.568Z"), "source_version": null, "update_version": ObjectId("5632e83550e3432edcf51b07") } }, { # 默认存在overview block,它是课程介绍页面的内容 "definition": ObjectId("5632e46950e3432ed9f51b0a"), "block_type": "about", "block_id": "overview", "fields": { "display_name": "overview" }, "defaults": { }, "edit_info": { "edited_by": NumberLong(9), "previous_version": null, "original_usage_version": null, "original_usage": null, "edited_on": ISODate("2015-10-30T03:30:49.558Z"), "source_version": null, "update_version": ObjectId("5632e46950e3432ed9f51b07") } } ], "root": [ "course", "course" ]}

XBlock Definitions存储具体的block,比如:

{ "_id": ObjectId("5632e46950e3432ed9f51b06"), "fields": { "wiki_slug": "test10org.test10code.2015" }, "edit_info": { "edited_on": ISODate("2015-10-30T03:30:49.380Z"), "edited_by": NumberLong(9), "original_version": ObjectId("5632e46950e3432ed9f51b06"), "previous_version": null }, "block_type": "course", "schema_version": 1}{ "_id": ObjectId("5632e46950e3432ed9f51b0a"), "fields": { "data": "
\n

About This Course

\n

Include your long course description here. The long course description should contain 150-400 words.

\n\n

This is paragraph 2 of the long course description. Add more paragraphs as needed. Make sure to enclose them in paragraph tags.

\n
\n\n
\n

Requirements

\n

Add information about the skills and knowledge students need to take this course.

\n
\n\n
\n

Course Staff

\n
\n
\n
\"Course\n
\n\n

Staff Member #1

\n

Biography of instructor/staff member #1

\n
\n\n
\n
\n
\"Course\n
\n\n

Staff Member #2

\n

Biography of instructor/staff member #2

\n
\n
\n\n
\n
\n

Frequently Asked Questions

\n
\n

Do I need to buy a textbook?

\n

No, a free online version of Chemistry: Principles, Patterns, and Applications, First Edition by Bruce Averill and Patricia Eldredge will be available, though you can purchase a printed version (published by FlatWorld Knowledge) if you’d like.

\n
\n\n
\n

Question #2

\n

Your answer would be displayed here.

\n
\n
\n
\n" }, "edit_info": { "edited_on": ISODate("2015-10-30T03:30:49.557Z"), "edited_by": NumberLong(9), "original_version": ObjectId("5632e46950e3432ed9f51b0a"), "previous_version": null }, "block_type": "about", "schema_version": 1}

 

Mongodb操作记录:

1. 更新指定条件其中多少条记录:

db.modulestore.active_versions.find({org:"LzSH"}).limit(50).forEach(function(doc){ db.modulestore.active_versions.update({_id:doc._id},{$set:{org:"LzSouth"}})})

 

转载于:https://my.oschina.net/moks/blog/1602264

你可能感兴趣的文章
poj 1011 Sticks ,剪枝神题
查看>>
H5实现拍照并上传
查看>>
为什么可以用while(cin)?
查看>>
解决: Fail to create empty document
查看>>
Nodejs·理解Buffer
查看>>
YII 实现布局
查看>>
kvm guest usb mapping
查看>>
Java IO的RandomAccessFile的使用(转)
查看>>
执行Asp.net应用程序在Linux上的3种托管方式
查看>>
CSS学习笔记——定位position属性的学习
查看>>
腾讯下一个重点:硬件;硬件自身的未来也正进入多元化发展
查看>>
数学之路-python计算实战(2)-初遇pypy
查看>>
细数JDK里的设计模式<转>
查看>>
自建博客随想录
查看>>
发现一个nginx LUA开发Web App的框架
查看>>
hdu 5640 King's Cake(模拟)
查看>>
Java之IO流总结
查看>>
LVM Linear vs Striped Logical Volumes
查看>>
Mysql主从备份和SQL语句的备份
查看>>
DEDECMS之三 首页、列表页怎么调用文章内容
查看>>